<%@ page import="protectjava.jsp.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 黑白客
  Date: 2019/6/2
  Time: 17:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--    模拟域中的数据--%>
    <%
        pageContext.setAttribute("company","黑白客");

        //存储字符串
        request.setAttribute("company","黑马程序员");

        //存储一个字符串
        User user = new User();
        user.setId(1);
        user.setName("zhangsan");
        user.setPassword("123");
        session.setAttribute("user",user);

//存储一个集合
        List<User> list = new ArrayList<User>();
        User user1 = new User();
        user1.setId(2);
        user1.setName("lisi");
        user1.setPassword("123");
        list.add(user1);
        User user3 = new User();
        user3.setId(4);
        user3.setName("wangwu");
        user3.setPassword("123");
        list.add(user3);
        application.setAttribute("list",list);
    %>

<%--脚本方法取出域的值--%>
<%=request.getAttribute("company")%>
<%
    User sessionUser = (User)session.getAttribute("user");
    out.write(sessionUser.getName());
%>

<%--使用EL表达式获得域中的值--%>
<hr/>
<%--使用EL获得域中的值--%>
${requestScope.company }
${sessionScope.user.name }
${applicationScope.list[1].name}

<%--使用el表达式 全域查找--%>
${company}
${user.name}
${list[1].name}
${list[1].name}

<%--el可以执行表达式运算--%>
${1+1}
${1==1?true:false}
<%--empty 判断某个对象是否是unll  是null返回true--%>
${empty list}
</body>
</html>
